home *** CD-ROM | disk | FTP | other *** search
/ Nejlepší hry / Nejlepsi hry.iso / hry / sea of chaos / sea_install.msi / _15C39AAA7726369D39812BD40F01CF6A / _BC2F2E833C104C4C8BAA217595E30C8A < prev    next >
Text File  |  2005-02-12  |  1KB  |  62 lines

  1. //wake in water particle shader
  2. //should be used with prtWake2.psh
  3. //Luke Lenhart
  4. //(C)2004-2005 Digipen Institute of Technology
  5.  
  6. //input position:
  7. //x,y = side of particle (either -1 or 1)
  8. //z = size of particle
  9.  
  10. //input vertex color:
  11. //a = alpha;
  12. //r(x) = x direction of wake
  13. //g(y) = y direction of wake
  14. //b = rotation angle of particle
  15.  
  16. //input tex coord = position in space
  17.  
  18. //world,view,projection transform
  19. float4x4 matViewProj;
  20.  
  21. //shader input
  22. struct VS_INPUT
  23. {
  24.     float4 Pos : POSITION;
  25.     float4 Clr : COLOR;
  26.     float2 Trans : TEXCOORD0;
  27. };
  28.  
  29. //shader output
  30. struct VS_OUTPUT
  31. {
  32.     float4 Pos : POSITION; //transformed out
  33.     float2 Side : TEXCOORD0; //side of particle model is on (-1 to 1) (.xy)
  34.     float4 Clr : COLOR;
  35. };
  36.  
  37. //shader code
  38. VS_OUTPUT VShader(VS_INPUT In)
  39. {
  40.     VS_OUTPUT Out;
  41.     
  42.     //rotate and scale particle (model space)
  43.     In.Clr.b*=3.14159*2;
  44.     float2x2 matRot={cos(In.Clr.b),sin(In.Clr.b),-sin(In.Clr.b),cos(In.Clr.b)};
  45.     float4 pos;
  46.     pos.xy=mul(matRot,In.Pos.xy)*In.Pos.z;
  47.     pos.z=pos.w=1;
  48.     
  49.     //translate and transform it
  50.     pos.xy+=In.Trans;
  51.     Out.Pos=mul(matViewProj,pos);
  52.     
  53.     //copy model coords to side, and copy direction through
  54.     Out.Side.xy=In.Pos.xy;
  55.     
  56.     //make color of wake
  57.     Out.Clr=float4(1,1,1,In.Clr.a*0.6f);
  58.  
  59.     //spit out the results
  60.     return Out;
  61. }
  62.